CC=g++
CFLAGS=-c -Wall
LFLAGS="-std=c++0x"
SRCDIR=src/google/fp_growth
DSTDIR=bin

all: make_target_dir copy_example_file dictionary_test header_test node_test itemsets_test tree_test transactions_file_impl_test transactions_memory_impl_test association_rules_test miner_memory_demo_main miner_file_demo_main miner_main

make_target_dir:
	-mkdir -p $(DSTDIR)
	-mkdir -p $(DSTDIR)/testdata
	-mkdir -p $(DSTDIR)/unittest

copy_example_file:
	-cp $(SRCDIR)/testdata/example.txt $(DSTDIR)/testdata/example.txt

dictionary_test:
	$(CC) $(LFLAGS) $(SRCDIR)/dictionary_test.cc $(SRCDIR)/common/logging.cc $(SRCDIR)/common/strutil.cc -o $(DSTDIR)/unittest/dictionary_test

header_test:
	$(CC) $(LFLAGS) $(SRCDIR)/header_test.cc $(SRCDIR)/header.cc $(SRCDIR)/common/logging.cc $(SRCDIR)/common/strutil.cc -o $(DSTDIR)/unittest/header_test

node_test:
	$(CC) $(LFLAGS) $(SRCDIR)/node_test.cc $(SRCDIR)/common/logging.cc -o $(DSTDIR)/unittest/node_test

itemsets_test:
	$(CC) $(LFLAGS) $(SRCDIR)/itemsets_test.cc $(SRCDIR)/common/logging.cc $(SRCDIR)/common/strutil.cc -o $(DSTDIR)/unittest/itemsets_test

tree_test:
	$(CC) $(LFLAGS) $(SRCDIR)/tree_test.cc $(SRCDIR)/header.cc $(SRCDIR)/common/logging.cc $(SRCDIR)/common/strutil.cc -o $(DSTDIR)/unittest/tree_test

transactions_file_impl_test:
	$(CC) $(LFLAGS) $(SRCDIR)/transactions_file_impl_test.cc $(SRCDIR)/common/logging.cc -o $(DSTDIR)/unittest/transactions_file_impl_test

transactions_memory_impl_test:
	$(CC) $(LFLAGS) $(SRCDIR)/transactions_memory_impl_test.cc $(SRCDIR)/common/logging.cc $(SRCDIR)/common/strutil.cc -o $(DSTDIR)/unittest/transactions_memory_impl_test

association_rules_test:
	$(CC) $(LFLAGS) $(SRCDIR)/association_rules_test.cc $(SRCDIR)/common/logging.cc $(SRCDIR)/common/strutil.cc -o $(DSTDIR)/unittest/association_rules_test

miner_memory_demo_main:
	$(CC) $(LFLAGS) $(SRCDIR)/miner_memory_demo_main.cc $(SRCDIR)/header.cc $(SRCDIR)/common/logging.cc $(SRCDIR)/common/strutil.cc -o $(DSTDIR)/miner_memory_demo_main

miner_file_demo_main:
	$(CC) $(LFLAGS) $(SRCDIR)/miner_file_demo_main.cc $(SRCDIR)/header.cc $(SRCDIR)/common/logging.cc $(SRCDIR)/common/strutil.cc -o $(DSTDIR)/miner_file_demo_main

miner_main:
	$(CC) $(LFLAGS) $(SRCDIR)/miner_main.cc $(SRCDIR)/header.cc $(SRCDIR)/common/logging.cc $(SRCDIR)/common/strutil.cc -o $(DSTDIR)/miner_main

clean:
	rm -f $(DSTDIR)/unittest/*
	rmdir $(DSTDIR)/unittest
	rm -f $(DSTDIR)/testdata/*
	rmdir $(DSTDIR)/testdata
	rm -f $(DSTDIR)/*
	rmdir $(DSTDIR)
